package threading;


import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class ThreadDemo12BlockingQueue {
    public static void main(String[] args) throws InterruptedException {
        //注意BlockingQueue是一个接口，只能实例化实现这个接口的类的对象
        BlockingQueue<String> blockingQueue = new LinkedBlockingQueue();
        // 1. put入队列
        blockingQueue.put("hello1");
        blockingQueue.put("hello2");
        blockingQueue.put("hello3");
        blockingQueue.put("hello4");
        blockingQueue.put("hello5");
        // 2. take出队列
        String ret = blockingQueue.take();
        System.out.println(ret);

        ret = blockingQueue.take();
        System.out.println(ret);

        ret = blockingQueue.take();
        System.out.println(ret);
    }
}
